import { useCourseStore } from "~/stores/course";
import {
  useAnswer,
  useSumUp,
  useTip,
  useInput as useInputStatus,
} from "~/composables/study/studentStatus";
import { usePlayTipSound } from "@/composables/study/useSound";
export function useStudyInput() {
  const courseStore = useCourseStore();
  const { showSumUp } = useSumUp();
  const { showTip, hideTip } = useTip();
  const { showInput, hideInput } = useInputStatus();
  const { playRightSound, playErrorSound } = usePlayTipSound();
  const { showAnswer, hideAnswer } = useAnswer();
  const AnswerRight = () => {
    playRightSound();
    showTip();
    hideInput();
    showAnswer();
  };

  const AnswerErr = () => {
    console.log("AnswerErr");
    console.log();

    courseStore.recordErrId();
    playErrorSound();
  };
  function goNext() {
    if (courseStore.isEnd()) {
      showSumUp();
      return;
    }
    hideTip();
    hideAnswer();
    showInput();
    console.log("goNext");
    courseStore.toNextData();
  }
  return {
    goNext,
    AnswerRight,
    AnswerErr,
    showSumUp,
  };
}
